//集团
const group = '00';
//饲料
const feed = '01';
//养殖
const livestock = '02';
//食品
const food = '03';
//种植
const planting = '04';
//人资
const hr = '05';
//协同
const synergy = '06';
//财务
const financial = '07';
//供应链
const scm = '08';
//物联网
const iot = '09';

//意见反馈
const fb = '10';

//简历评估
const rd = '11';
//销售日报
const bi = '12';

/**
 * @summary板块
 * @template顺序维护即可禁止使用数字0开头数字JavaScript会解析成8进制
 */
const SNPlate = {
    group,
    feed,
    livestock,
    food,
    planting,
    hr,
    synergy,
    financial,
    scm,
    fb,
    rd,
    bi,
};

const sequenceTwo00 = '00';

const sequenceTwo01 = '01';

const sequenceTwo02 = '02';

const sequenceTwo03 = '03';

const sequenceTwo04 = '04';

const sequenceTwo05 = '05';

const sequenceTwo06 = '06';

/**
 * @summary业务
 * @template维护sequenceTwo
 * @template维护routingGuard____路由守卫只需要添加模块时才进行维护
 * @template维护getFood____维护业务顺序添加即可
 */
const SNBusiness = {
    sequenceTwo00,
    sequenceTwo01,
    sequenceTwo02,
    sequenceTwo03,
    sequenceTwo04,
    sequenceTwo05,
    sequenceTwo06,
};

/**
 * 序列二路由守卫
 * @param {*} type1
 * @param {*} type2
 * @returns
 */
const routingGuard = (type1, type2) => {
    return {
        [SNPlate.group]: getGroup(type2),
        [SNPlate.food]: getFood(type2),
        [SNPlate.hr]: getHr(type2),
        [SNPlate.livestock]: getPig(type2),
        [SNPlate.scm]: getScm(type2),
        [SNPlate.fb]: getFb(type2),
        [SNPlate.rd]: getRD(type2),
        [SNPlate.bi]: getBI(type2),
    }[type1][0];
};

/**
 * 集团模块001
 * 维护方式 : 添加序号对应内容即可
 * 1、添加序列：sequenceTwo01
 * 2、
 * @param {*} type
 * @returns
 */
const getGroup = (type) => {
    return {
        [sequenceTwo01]: [],
    }[type];
};

/**
 * 食品
 * @param {*} type
 * @returns
 */
const getFood = (type) => {
    return {
        [sequenceTwo02]: ['bizreport/food/', '食品'],
        [sequenceTwo01]: ['bizreport/bi/food/', '屠宰'],
        [sequenceTwo00]: ['', '电子签章'],
    }[type];
};

const getHr = (type) => {
    return {
        [sequenceTwo00]: ['biz/workreport/', '工作汇报'],
    }[type];
};

const getScm = (type) => {
    return {
        [sequenceTwo01]: ['bizreport/scm/', '大原料库存'],
    }[type];
};
const getFb = (type) => {
    return {
        [sequenceTwo01]: ['biz/feedback/', '意见反馈详情'],
    }[type];
};
const getRD = (type) => {
    return {
        [sequenceTwo01]: ['lookrecruit/', '简历评估详情'],
    }[type];
};

/**
 * 生猪养殖
 * @param {*} type
 * @returns
 */
const getPig = (type) => {
    return {
        [sequenceTwo03]: ['bizreport/bi/livestock/', '批次存栏'],
        [sequenceTwo04]: ['biosafety/', '审查表'],
        [sequenceTwo05]: ['breed/entryrgst/', '入厂登记'],
        [sequenceTwo06]: ['breed/inboundplan/', '入厂计划'],
    }[type];
};
/**
 * 销售日报
 * @param {*} type
 * @returns
 */
const getBI = (type) => {
    return {
        [sequenceTwo01]: ['bizreport/bi/livestock/', '销售日报'],
    }[type];
};

const sequenceThree000 = '000';

const sequenceThree001 = '001';

const sequenceThree002 = '002';

const sequenceThree003 = '003';

const sequenceThree004 = '004';

const sequenceThree005 = '005';

const sequenceThree006 = '006';

const sequenceThree007 = '007';

/**
 * 序列三路由守卫
 * @param {*} type1
 * @param {*} type2
 * @returns
 */
const routingGuard3 = (type0, type1, type2) => {
    switch (type0) {
        case SNPlate.food:
            return {
                [SNBusiness.sequenceTwo01]: getFoodSlaughter(type2),
                [SNBusiness.sequenceTwo00]: getFoodSlaughter(type2),
                [SNBusiness.sequenceTwo02]: getFoodSlaughter(type2),
            }[type1][0];
        case SNPlate.livestock:
            return {
                [SNBusiness.sequenceTwo03]: getBatchStock(type2),
                [SNBusiness.sequenceTwo04]: getBatchStock(type2),
                [SNBusiness.sequenceTwo05]: getBatchStock(type2),
                [SNBusiness.sequenceTwo06]: getBatchStock(type2),
            }[type1][0];
        case SNPlate.hr:
            return {
                [SNBusiness.sequenceTwo00]: getHrModel(type2),
            }[type1][0];
        case SNPlate.scm:
            return {
                [SNBusiness.sequenceTwo01]: getSCMModel(type2),
            }[type1][0];
        case SNPlate.fb:
            return {
                [SNBusiness.sequenceTwo01]: getFBModel(type2),
            }[type1][0];
        case SNPlate.rd:
            return {
                [SNBusiness.sequenceTwo01]: getRDModel(type2),
                [SNBusiness.sequenceTwo02]: getRDModel(type2),
            }[type1][0];
        case SNPlate.bi:
            return {
                [SNBusiness.sequenceTwo01]: getSRModel(type2),
            }[type1][0];
        default:
            return '';
    }
};

/**
 * 食品屠宰
 * @param {*} type
 * @returns
 */
const getFoodSlaughter = (type) => {
    return {
        [SNModule.sequenceThree001]: ['pigsltrdailyinfo.html', '日报'],
        [SNModule.sequenceThree002]: ['pigweighingsinfo.html', '过磅详情'],
        [SNModule.sequenceThree007]: ['main.html', '电子签章'],
        [SNModule.sequenceThree006]: ['statement.html', '报表'],
    }[type];
};

const getHrModel = (type) => {
    return {
        [SNModule.sequenceThree000]: ['workreportmain.html', '工作汇报'],
    }[type];
};

const getSCMModel = (type) => {
    return {
        [SNModule.sequenceThree001]: ['bulkinventorylog.html', '大原料库存页面'],
    }[type];
};

/**
 * 生猪养殖批次存栏
 * @param {*} type
 * @returns
 */
const getBatchStock = (type) => {
    return {
        [SNModule.sequenceThree001]: ['stocksituation.html', '存栏日报'],
        [SNModule.sequenceThree002]: ['detailsaudit.html', '审查表详情'],
        [SNModule.sequenceThree003]: ['addentryrgst.html', '入场登记'],
        [SNModule.sequenceThree004]: ['auditmain.html', '审查表列表'],
        [SNModule.sequenceThree005]: ['inboundplanlist.html', '入厂计划列表'],
        [SNModule.sequenceThree007]: ['detailsaudit.html', '审查表详情'],
    }[type];
};
// 意见反馈
const getFBModel = (type) => {
    return {
        [SNModule.sequenceThree001]: ['cgdetails.html', '意见反馈详情'],

        [SNModule.sequenceThree002]: ['hddetails.html', '安全隐患详情'],
    }[type];
};
const getRDModel = (type) => {
    return {
        [SNModule.sequenceThree001]: ['recruitdetails.html', '简历评估详情'],
        [SNModule.sequenceThree002]: ['lookrecruit.html', '简历评估列表'],
    }[type];
};
const getSRModel = (type) => {
    return {
        [SNModule.sequenceThree001]: ['salesdaily.html', '销售日报'],
    }[type];
};

/**
 * @summary功能
 * @template维护sequenceThree
 * @template维护routingGuard____路由守卫只需要添加模块时才进行维护
 * @template维护getFoodSlaughter____维护业务顺序添加即可
 */
const SNModule = {
    sequenceThree000,
    sequenceThree001,
    sequenceThree002,
    sequenceThree003,
    sequenceThree004,
    sequenceThree005,
    sequenceThree006,
    sequenceThree007,
};

/**
 * @summary路由分发
 */
export default class SequenceRouter {
    /**
     * 路由解析
     * @param {*} type
     * @returns [url]
     */
    static getRouterPath(type) {
        if (type) {
            if (type.length != 7) return '';
            let _sequenceOne = type.substr(0, 2);
            let _sequenceTwo = type.substr(2, 2);
            let _sequenceThree = type.substr(4, 6);
            return `${routingGuard(_sequenceOne, _sequenceTwo)}${routingGuard3(_sequenceOne, _sequenceTwo, _sequenceThree)}`;
        }
        return '';
    }
}
